﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using SusuCMS.Web;
using System.Web;

namespace SusuCMS
{
    public class CmsApplication
    {
        private static readonly string PAGE_CONTEXT = "PageContext";

        public static IUnitOfWork GetDataContext()
        {
            return new CmsDataContext();
        }

        public static PageContext GePageContext()
        {
            return HttpContext.Current.Items[PAGE_CONTEXT] as PageContext;
        }

        public static void SetPageContext(PageContext pageContext)
        {
            HttpContext.Current.Items.Add(PAGE_CONTEXT, pageContext);
        }

        public static IPageRepository GetPageRepository(IUnitOfWork unitOfWork)
        {
            return new PageRepository(unitOfWork);
        }

        public static IPageTypeRepository GetPageTypeRepository(IUnitOfWork unitOfWork)
        {
            return new PageTypeRepository(unitOfWork);
        }

        public static IWebsiteRepository GetWebsiteRepository(IUnitOfWork unitOfWork)
        {
            return new WebsiteRepository(unitOfWork);
        }

        public static IUserRepository GetUserRepository(IUnitOfWork unitOfWork)
        {
            return new UserRepository(unitOfWork);
        }
    }
}
